home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Think Class Libraries / TP TCL->CW TCL v1.1.2.3 / UPI ƒ / Updated UPIs ƒ / MixedMode.p < prev    next >
Text File  |  1996-02-07  |  8KB  |  313 lines

  1. {
  2.      File:        MixedMode.p
  3.  
  4.      Contains:    Mixed Mode Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT MixedMode;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __MIXEDMODE__}
  30. {$SETC __MIXEDMODE__ := 1}
  31.  
  32. {$I+}
  33. {$SETC MixedModeIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$PUSH}
  43. {$ALIGN MAC68K}
  44. {$LibExport+}
  45.  
  46. CONST
  47.     kRoutineDescriptorVersion    = 7;
  48.  
  49. { MixedModeMagic Magic Cookie/Trap number }
  50.     _MixedModeMagic                = $AAFE;
  51.  
  52. { Calling Conventions }
  53.     
  54. TYPE
  55.     CallingConventionType = INTEGER;
  56.  
  57.  
  58. CONST
  59.     kPascalStackBased            = 0;
  60.     kCStackBased                = 1;
  61.     kRegisterBased                = 2;
  62.     kD0DispatchedPascalStackBased = 8;
  63.     kD1DispatchedPascalStackBased = 12;
  64.     kD0DispatchedCStackBased    = 9;
  65.     kStackDispatchedPascalStackBased = 14;
  66.     kThinkCStackBased            = 5;
  67.  
  68. { ISA Types }
  69.     
  70. TYPE
  71.     ISAType = SInt8;
  72.  
  73.  
  74. CONST
  75.     kM68kISA                    = 0;
  76.     kPowerPCISA                    = 1;
  77.  
  78. { RTA Types }
  79.     
  80. TYPE
  81.     RTAType = SInt8;
  82.  
  83.  
  84. CONST
  85.     kOld68kRTA                    = 0+(0 * (2**(4)));
  86.     kPowerPCRTA                    = 0+(0 * (2**(4)));
  87.     kCFM68kRTA                    = 0+(1 * (2**(4)));
  88.  
  89. {$IFC GENERATINGPOWERPC }
  90.     GetCurrentISA                = kPowerPCISA;
  91.     GetCurrentRTA                = kPowerPCRTA;
  92.  
  93. {$ELSEC}
  94. {$IFC GENERATINGCFM }
  95.     GetCurrentISA                = kM68kISA;
  96.     GetCurrentRTA                = kCFM68kRTA;
  97.  
  98. {$ELSEC}
  99.     GetCurrentISA                = kM68kISA;
  100.     GetCurrentRTA                = kOld68kRTA;
  101.  
  102. {$ENDC}
  103. {$ENDC}
  104.     GetCurrentArchitecture        = 0+(GetCurrentISA + GetCurrentRTA);
  105.  
  106.     kRegisterD0                    = 0;
  107.     kRegisterD1                    = 1;
  108.     kRegisterD2                    = 2;
  109.     kRegisterD3                    = 3;
  110.     kRegisterD4                    = 8;
  111.     kRegisterD5                    = 9;
  112.     kRegisterD6                    = 10;
  113.     kRegisterD7                    = 11;
  114.     kRegisterA0                    = 4;
  115.     kRegisterA1                    = 5;
  116.     kRegisterA2                    = 6;
  117.     kRegisterA3                    = 7;
  118.     kRegisterA4                    = 12;
  119.     kRegisterA5                    = 13;
  120.     kRegisterA6                    = 14;
  121. { A7 is the same as the PowerPC SP }
  122.     kCCRegisterCBit                = 16;
  123.     kCCRegisterVBit                = 17;
  124.     kCCRegisterZBit                = 18;
  125.     kCCRegisterNBit                = 19;
  126.     kCCRegisterXBit                = 20;
  127.  
  128.     
  129. TYPE
  130.     registerSelectorType = INTEGER;
  131.  
  132. { SizeCodes we use everywhere }
  133.  
  134. CONST
  135.     kNoByteCode                    = 0;
  136.     kOneByteCode                = 1;
  137.     kTwoByteCode                = 2;
  138.     kFourByteCode                = 3;
  139.  
  140. { Mixed Mode Routine Records }
  141.     
  142. TYPE
  143.     ProcInfoType = LONGINT;
  144.  
  145. { Routine Flag Bits }
  146.     RoutineFlagsType = INTEGER;
  147.  
  148.  
  149. CONST
  150.     kProcDescriptorIsAbsolute    = $00;
  151.     kProcDescriptorIsRelative    = $01;
  152.  
  153.     kFragmentIsPrepared            = $00;
  154.     kFragmentNeedsPreparing        = $02;
  155.  
  156.     kUseCurrentISA                = $00;
  157.     kUseNativeISA                = $04;
  158.  
  159.     kPassSelector                = $0;
  160.     kDontPassSelector            = $08;
  161.  
  162.     kRoutineIsNotDispatchedDefaultRoutine = $0;
  163.     kRoutineIsDispatchedDefaultRoutine = $10;
  164.  
  165.  
  166. TYPE
  167.     RoutineRecord = RECORD
  168.         procInfo:                ProcInfoType;                            { calling conventions }
  169.         reserved1:                SInt8; (* UInt8 *)                        { Must be 0 }
  170.         ISA:                    ISAType;                                { Instruction Set Architecture }
  171.         routineFlags:            RoutineFlagsType;                        { Flags for each routine }
  172.         procDescriptor:            ProcPtr;                                { Where is the thing we’re calling? }
  173.         reserved2:                UInt32;                                    { Must be 0 }
  174.         selector:                UInt32;                                    { For dispatched routines, the selector }
  175.     END;
  176.  
  177.     RoutineRecordPtr = ^RoutineRecord;
  178.     RoutineRecordHandle = ^RoutineRecordPtr;
  179.  
  180. { Mixed Mode Routine Descriptors }
  181. { Definitions of the Routine Descriptor Flag Bits }
  182.     RDFlagsType = UInt8;
  183.  
  184.  
  185. CONST
  186.     kSelectorsAreNotIndexable    = $00;
  187.     kSelectorsAreIndexable        = $01;
  188.  
  189. { Routine Descriptor Structure }
  190.  
  191. TYPE
  192.     RoutineDescriptor = PACKED RECORD
  193.         goMixedModeTrap:        UInt16;                                    { Our A-Trap }
  194.         version:                SInt8;                                    { Current Routine Descriptor version }
  195.         routineDescriptorFlags:    RDFlagsType;                            { Routine Descriptor Flags }
  196.         reserved1:                UInt32;                                    { Unused, must be zero }
  197.         reserved2:                UInt8;                                    { Unused, must be zero }
  198.         selectorInfo:            UInt8;                                    { If a dispatched routine, calling convention, else 0 }
  199.         routineCount:            UInt16;                                    { Number of routines in this RD }
  200.         routineRecords:            ARRAY [0..0] OF RoutineRecord;            { The individual routines }
  201.     END;
  202.  
  203.     RoutineDescriptorPtr = ^RoutineDescriptor;
  204.     RoutineDescriptorHandle = ^RoutineDescriptorPtr;
  205.  
  206.  
  207. CONST
  208. { Calling Convention Offsets }
  209.     kCallingConventionWidth        = 4;
  210.     kCallingConventionPhase        = 0;
  211.     kCallingConventionMask        = $F;
  212. { Result Offsets }
  213.     kResultSizeWidth            = 2;
  214.     kResultSizePhase            = kCallingConventionWidth;
  215.     kResultSizeMask                = $30;
  216. { Parameter offsets & widths }
  217.     kStackParameterWidth        = 2;
  218.     kStackParameterPhase        = 0+(kCallingConventionWidth + kResultSizeWidth);
  219.     kStackParameterMask            = $FFFFFFC0;
  220. { Register Result Location offsets & widths }
  221.     kRegisterResultLocationWidth = 5;
  222.     kRegisterResultLocationPhase = 0+(kCallingConventionWidth + kResultSizeWidth);
  223. { Register Parameter offsets & widths }
  224.     kRegisterParameterWidth        = 5;
  225.     kRegisterParameterPhase        = 0+(kCallingConventionWidth + kResultSizeWidth + kRegisterResultLocationWidth);
  226.     kRegisterParameterMask        = $7FFFF800;
  227.     kRegisterParameterSizePhase    = 0;
  228.     kRegisterParameterSizeWidth    = 2;
  229.     kRegisterParameterWhichPhase = kRegisterParameterSizeWidth;
  230.     kRegisterParameterWhichWidth = 3;
  231. { Dispatched Stack Routine Selector offsets & widths }
  232.     kDispatchedSelectorSizeWidth = 2;
  233.     kDispatchedSelectorSizePhase = 0+(kCallingConventionWidth + kResultSizeWidth);
  234. { Dispatched Stack Routine Parameter offsets }
  235.     kDispatchedParameterPhase    = 0+(kCallingConventionWidth + kResultSizeWidth + kDispatchedSelectorSizeWidth);
  236. { Special Case offsets & widths }
  237.     kSpecialCaseSelectorWidth    = 6;
  238.     kSpecialCaseSelectorPhase    = kCallingConventionWidth;
  239.     kSpecialCaseSelectorMask    = $3F0;
  240. { Component Manager Special Case offsets & widths }
  241.     kComponentMgrResultSizeWidth = 2;
  242.     kComponentMgrResultSizePhase = kCallingConventionWidth + kSpecialCaseSelectorWidth; { 4 + 6 = 10 }
  243.     kComponentMgrParameterWidth    = 2;
  244.     kComponentMgrParameterPhase    = kComponentMgrResultSizePhase + kComponentMgrResultSizeWidth; { 10 + 2 = 12 }
  245.  
  246.     kSpecialCase                = $0000000F;
  247.  
  248. { all of the special cases enumerated.  The selector field is 6 bits wide }
  249.     kSpecialCaseHighHook        = 0;
  250.     kSpecialCaseCaretHook        = 0;                            { same as kSpecialCaseHighHook }
  251.     kSpecialCaseEOLHook            = 1;
  252.     kSpecialCaseWidthHook        = 2;
  253.     kSpecialCaseTextWidthHook    = 2;                            { same as kSpecialCaseWidthHook }
  254.     kSpecialCaseNWidthHook        = 3;
  255.     kSpecialCaseDrawHook        = 4;
  256.     kSpecialCaseHitTestHook        = 5;
  257.     kSpecialCaseTEFindWord        = 6;
  258.     kSpecialCaseProtocolHandler    = 7;
  259.     kSpecialCaseSocketListener    = 8;
  260.     kSpecialCaseTERecalc        = 9;
  261.     kSpecialCaseTEDoText        = 10;
  262.     kSpecialCaseGNEFilterProc    = 11;
  263.     kSpecialCaseMBarHook        = 12;
  264.     kSpecialCaseComponentMgr    = 13;
  265.  
  266. {$IFC GENERATINGCFM }
  267.  
  268. FUNCTION NewRoutineDescriptor(theProc: ProcPtr; theProcInfo: ProcInfoType; theISA: ByteParameter): UniversalProcPtr;
  269.     {$IFC NOT GENERATINGCFM}
  270.     INLINE $7000, $AA59;
  271.     {$ENDC}
  272. PROCEDURE DisposeRoutineDescriptor(theProcPtr: UniversalProcPtr);
  273.     {$IFC NOT GENERATINGCFM}
  274.     INLINE $7001, $AA59;
  275.     {$ENDC}
  276. FUNCTION NewFatRoutineDescriptor(theM68kProc: ProcPtr; thePowerPCProc: ProcPtr; theProcInfo: ProcInfoType): UniversalProcPtr;
  277.     {$IFC NOT GENERATINGCFM}
  278.     INLINE $7002, $AA59;
  279.     {$ENDC}
  280. {$ELSEC}
  281.  
  282. FUNCTION NewRoutineDescriptor(theProc: ProcPtr; theProcInfo: ProcInfoType; theISA: ByteParameter): UniversalProcPtr;
  283.     {$IFC NOT GENERATINGCFM}
  284.     INLINE $5C4F, $2E9F;
  285.     {$ENDC}
  286. PROCEDURE DisposeRoutineDescriptor(theProcPtr: UniversalProcPtr);
  287.     {$IFC NOT GENERATINGCFM}
  288.     INLINE $584F;
  289.     {$ENDC}
  290. {$ENDC}
  291. {$IFC CFMSYSTEMCALLS }
  292. {$IFC NOT LSPWRP & NOT LSP68K | MWERKS}
  293. {     NB [
  294. FUNCTION CallUniversalProc(theProcPtr: UniversalProcPtr; procInfo: ProcInfoType; ...): LONGINT; C;
  295. FUNCTION CallOSTrapUniversalProc(theProcPtr: UniversalProcPtr; procInfo: ProcInfoType; ...): LONGINT; C;
  296.     NB ] 
  297. }
  298. FUNCTION CallUniversalProc(theProcPtr: UniversalProcPtr; procInfo: ProcInfoType; ...): LONGINT; C; EXTERNAL;
  299. FUNCTION CallOSTrapUniversalProc(theProcPtr: UniversalProcPtr; procInfo: ProcInfoType; ...): LONGINT; C; EXTERNAL;
  300. {$ENDC}
  301. {$ENDC}
  302.  
  303. {$ALIGN RESET}
  304. {$POP}
  305.  
  306. {$SETC UsingIncludes := MixedModeIncludes}
  307.  
  308. {$ENDC} {__MIXEDMODE__}
  309.  
  310. {$IFC NOT UsingIncludes}
  311.  END.
  312. {$ENDC}
  313.